package com.mlingdu.ffmpegaudioplayer.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

import com.mlingdu.ffmpegaudioplayer.common.jni.FFmpegAudioPlayer;
import com.mlingdu.ffmpegaudioplayer.R;

/**
 * Created by daimaren on 2017/12/16
 * 975808394@qq.com
 * 使用OpenSL ES 和FFmpeg播放网络音频流
 */

public class FFmpegAudioPlayerActivity extends AppCompatActivity {
	private EditText mInput;
	//目前只支持HTTP地址
	private static final String HttpsCloudMusicUrl = "https://m7.music.126.net/20171216135427/baceebf3428624eed8d6ce612a1377b1/ymusic/3fc1/2443/7a16/ea590bb10d086ca3d6d47a46609f9973.mp3";
	private static final String HttpMusicUrl = "http://sc1.111ttt.com:8282/2017/4/05m/10/298101104389.m4a?#.mp3";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_ffmpeg_audio_player);
		initView();
	}
	private void initView(){
		mInput = (EditText) findViewById(R.id.et_input);
		mInput.setText(HttpMusicUrl);
		findViewById(R.id.bt_play).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				FFmpegAudioPlayer.play(mInput.getText().toString().trim());
			}
		});
		findViewById(R.id.bt_pause).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				FFmpegAudioPlayer.stop();
			}
		});
	}
}
